@using Microsoft.AspNetCore.Identity
@using OrchardCore.Entities
@using OrchardCore.Settings
@using OrchardCore.Users
@using OrchardCore.Users.Models
@model OrchardCore.Users.ViewModels.RegisterViewModel

@inject ISiteService SiteService
@{
  ViewLayout = "Layout__Login";
  var disableLocalLogin = (await SiteService.GetSiteSettingsAsync()).As<LoginSettings>().DisableLocalLogin;

  ViewData.ModelState.TryGetValue("UserName", out var userName);
  ViewData.ModelState.TryGetValue("Email", out var email);
  ViewData.ModelState.TryGetValue("Password", out var password);
  ViewData.ModelState.TryGetValue("ConfirmPassword", out var confirmPassword);
}
<v-card class="px-4">
  <form id="form" asp-controller="Registration" asp-action="Register" asp-route-returnurl="@ViewData["ReturnUrl"]" method="post">
    <v-card-title>@T["Create account"]</v-card-title>
    <v-card-subtitle>@T["Register for your hackathon account here"]</v-card-subtitle>
    <v-card-text>
      <v-row>
        <v-col>
            @if (ViewData.ModelState.ErrorCount > 0)
            {
              <v-alert color="red" type="error">
                <ul>
                  @foreach (var error in ViewData.ModelState.SelectMany(x => x.Value.Errors).Reverse())
                  {
                    <li>@error.ErrorMessage</li>
                  }
                </ul>
              </v-alert>
            }
            <v-text-field id="UserName" name="UserName" label="@T["Username"]" value="@userName?.AttemptedValue"
              error-messages="@(userName?.Errors.FirstOrDefault()?.ErrorMessage)"></v-text-field>
            <v-text-field id="Email" type="email" name="Email" label="@T["Email"]" value="@email?.AttemptedValue"
              error-messages="@(email?.Errors.FirstOrDefault()?.ErrorMessage)"></v-text-field>
            <v-text-field id="Password" type="password" name="Password" label="@T["Password"]"
              error-messages="@(password?.Errors.FirstOrDefault()?.ErrorMessage)">
            </v-text-field>
            <v-text-field id="ConfirmPassword" type="password" name="ConfirmPassword" label="@T["Confirm password"]"
              error-messages="@(confirmPassword?.Errors.FirstOrDefault()?.ErrorMessage)">
            </v-text-field>
        </v-col>
      </v-row>
    </v-card-text>
    <v-card-actions>
      @await RenderSectionAsync("AfterRegister", required: false)
      <v-btn type="submit" x-large block color="success">@T["Create account"]</v-btn>
    </v-card-actions>
    @if (!disableLocalLogin)
    {
      <div class="d-flex align-center">
        <v-divider></v-divider><span class="px-2">@T["or"]</span>
        <v-divider></v-divider>
      </div>
      @* <span>@T["Already have an account?"]</span> *@
      <v-card-actions>
        <v-btn href="@Url.Action("Login", "Account", new { Area = "OrchardCore.Users", returnUrl=ViewData["ReturnUrl"] })" x-large block color="grey lighten-2">@T["Log in"]</v-btn>
      </v-card-actions>
    }
  </form>
</v-card>